<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">

		<title>添加设备维护信息</title>
		<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="assets/css/font-awesome.min.css">
		<link rel="stylesheet" type="text/css" href="assets/css/select2.min.css">
		<link rel="stylesheet" type="text/css" href="assets/css/bootstrap-datetimepicker.min.css">
		<link rel="stylesheet" type="text/css" href="assets/css/style.css">
		<!--[if lt IE 9]>
		<script src="assets/js/html5shiv.min.js"></script>
		<script src="assets/js/respond.min.js"></script>
	<![endif]-->
	</head>

	<body>
		<div class="main-wrapper">
			<div class="header">
				<div class="header-left">
					<a href="index.html" class="logo">
						<img src="assets/img/logo.png" width="35" height="35" alt=""> <span>浑水摸鱼</span>
					</a>
				</div>
				<a id="toggle_btn" href="javascript:void(0);"><i class="fa fa-bars"></i></a>
				<a id="mobile_btn" class="mobile_btn float-left" href="#sidebar"><i class="fa fa-bars"></i></a>
				<ul class="nav user-menu float-right">
					<li class="nav-item dropdown has-arrow">
						<a href="#" class="dropdown-toggle nav-link user-link" data-toggle="dropdown">
							<span class="user-img"><img class="rounded-circle" src="assets/img/user.jpg" width="40"
									alt="Admin">
								<span class="status online"></span></span>
							<span>Admin</span>
						</a>
						<div class="dropdown-menu">
							<a class="dropdown-item" href="profile.html">My Profile</a>
							<a class="dropdown-item" href="edit-profile.html">Edit Profile</a>
							<a class="dropdown-item" href="settings.html">Settings</a>
							<a class="dropdown-item" href="login.html">Logout</a>
						</div>
					</li>
				</ul>
			</div>
			<div class="sidebar" id="sidebar">
				<div class="sidebar-inner slimscroll">
					<div id="sidebar-menu" class="sidebar-menu">
						<ul>
							<li class="menu-title">Main</li>
							<li>
								<a href="experience.html"><i class="fa fa-wheelchair"></i> <span>经验</span></a>
							</li>
							<li>
								<a href="arrange.html"><i class="fa fa-calendar-check-o"></i> <span>维护信息</span></a>
							</li>
							<li>
								<a href="liaisons.html"><i class="fa fa-user"></i> <span> 联系人 </span></a>
							</li>
							<li>
								<a href="record.html"><i class="fa fa-calendar"></i> <span> Record </span></a>
							</li>
							<li class="active">
								<a href="etextxx.html"><i class="fa fa-comments"></i> <span> Texts </span></a>
							</li>
						</ul>
						</li>
						</ul>
					</div>
				</div>
			</div>

			<div class="page-wrapper">
				<div class="content">
					<div class="row">
						<div class="col-sm-12">
							<h4 class="page-title">添加信息</h4>
						</div>
					</div>
					<form id="myForm">
						<div class="card-box">
							<h3 class="card-title">基础信息</h3>
							<div class="row">
								<div class="col-md-12">
									<div class="profile-basic">
										<div class="row">
											<div class="col-md-6">
												<div class="form-group form-focus">
													<label class="focus-label">所属用户</label>
													<input type="text" class="form-control floating" placeholder="请输入所属用户"
														id="operator">
												</div>
											</div>
											<div class="col-md-6">
												<div class="form-group form-focus">
													<label class="focus-label">发送人</label>
													<input type="text" class="form-control floating" placeholder="请输入发送人"
														id="deliver">
												</div>
											</div>
											<div class="col-md-6">
												<div class="form-group form-focus">
													<label class="focus-label">系统短信内容</label>
													<input class="form-control floating" type="text" placeholder="内容"
														id="main">
												</div>
											</div>
											<div class="col-md-6">
												<div class="form-group form-focus">
													<label class="focus-label">创建时间</label>
													<div class="cal-icon">
														<input class="form-control floating datetimepicker" type="text"
															pleaceholder="23/05/06" id="pubdate"><!-- 今天的日期 -->
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="text-center m-t-20">
							<button class="btn btn-primary submit-btn" type="submit">保存</button>
						</div>
					</form>
				</div>
			</div>
		</div>
		<div class="sidebar-overlay" data-reff=""></div>
		<script src="assets/js/jquery-3.2.1.min.js"></script>
		<script src="assets/js/popper.min.js"></script>
		<script src="assets/js/bootstrap.min.js"></script>
		<script src="assets/js/jquery.slimscroll.js"></script>
		<script src="assets/js/select2.min.js"></script>
		<script src="assets/js/moment.min.js"></script>
		<script src="assets/js/bootstrap-datetimepicker.min.js"></script>
		<script src="assets/js/app.js"></script>
		<script>
			$("#pubdate").datetimepicker({
				format: 'YYYY-MM-DD',
				locale: moment.locale('zh-CN')
			});
			// 先后端更新参数
			$(document).ready(function() {
				$('#myForm').submit(function(event) {
					event.preventDefault(); // 防止表单提交
					var date = $('#pubdate').data("DateTimePicker").date().toDate();
					console.log(date)
					var paprem = {
						'operator': $('#operator').val(),
						'deliver': $('#deliver').val(),
						'main': $('#main').val(),
						'pubdate': Date.parse(date).toString(),
						'identify':'否'
					}
					console.log(paprem);
					$.ajax({
						type: 'POST',
						dataType: 'json',
						url: 'http://localhost:8080/back/texts/push',
						contentType: "application/json",
						data: JSON.stringify(paprem),
						success: function(d) {
							console.log(d)
							if (d.code == '200') {
								alert("添加成功！");
								history.go(-1);
							} else {
								alert("添加失败！")
							}
						}
					})
				})
			});
		</script>
	</body>

</html>
